package Mangos::DB::Characters::Characters;

use strict;
use warnings;

use base qw(Mangos::DB::Characters);

__PACKAGE__->meta->setup
(
    table   => 'characters',

    columns => 
    [
        guid                 => { type => 'integer', not_null => 1 },
        account              => { type => 'integer', default => '0', not_null => 1 },
        data                 => { type => 'scalar', length => 4294967295 },
        name                 => { type => 'varchar', default => '', length => 12, not_null => 1 },
        race                 => { type => 'integer', default => '0', not_null => 1 },
        class                => { type => 'integer', default => '0', not_null => 1 },
        gender               => { type => 'integer', default => '0', not_null => 1 },
        level                => { type => 'integer', default => '0', not_null => 1 },
        xp                   => { type => 'integer', default => '0', not_null => 1 },
        money                => { type => 'integer', default => '0', not_null => 1 },
        playerBytes          => { type => 'integer', default => '0', not_null => 1 },
        playerBytes2         => { type => 'integer', default => '0', not_null => 1 },
        playerFlags          => { type => 'integer', default => '0', not_null => 1 },
        position_x           => { type => 'float', default => '0', not_null => 1, precision => 32 },
        position_y           => { type => 'float', default => '0', not_null => 1, precision => 32 },
        position_z           => { type => 'float', default => '0', not_null => 1, precision => 32 },
        map                  => { type => 'integer', default => '0', not_null => 1 },
        dungeon_difficulty   => { type => 'integer', default => '0', not_null => 1 },
        orientation          => { type => 'float', default => '0', not_null => 1, precision => 32 },
        taximask             => { type => 'scalar', length => 4294967295 },
        online               => { type => 'integer', default => '0', not_null => 1 },
        cinematic            => { type => 'integer', default => '0', not_null => 1 },
        totaltime            => { type => 'integer', default => '0', not_null => 1 },
        leveltime            => { type => 'integer', default => '0', not_null => 1 },
        logout_time          => { type => 'bigint', default => '0', not_null => 1 },
        is_logout_resting    => { type => 'integer', default => '0', not_null => 1 },
        rest_bonus           => { type => 'float', default => '0', not_null => 1, precision => 32 },
        resettalents_cost    => { type => 'integer', default => '0', not_null => 1 },
        resettalents_time    => { type => 'bigint', default => '0', not_null => 1 },
        trans_x              => { type => 'float', default => '0', not_null => 1, precision => 32 },
        trans_y              => { type => 'float', default => '0', not_null => 1, precision => 32 },
        trans_z              => { type => 'float', default => '0', not_null => 1, precision => 32 },
        trans_o              => { type => 'float', default => '0', not_null => 1, precision => 32 },
        transguid            => { type => 'bigint', default => '0', not_null => 1 },
        extra_flags          => { type => 'integer', default => '0', not_null => 1 },
        stable_slots         => { type => 'integer', default => '0', not_null => 1 },
        at_login             => { type => 'integer', default => '0', not_null => 1 },
        zone                 => { type => 'integer', default => '0', not_null => 1 },
        death_expire_time    => { type => 'bigint', default => '0', not_null => 1 },
        taxi_path            => { type => 'text', length => 65535 },
        arena_pending_points => { type => 'integer', default => '0', not_null => 1 },
    ],

    relationships => 
    [
       Account =>
        {
            type => 'one to one',
            class => 'Mangos::DB::Realmd::Account',
            column_map => { account => 'id' },
        },
 
        Auctionhouse =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::Auctionhouse',
            column_map => { guid => 'itemowner' },
        },
        
        CharacterAchievement =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterAchievement',
            column_map => { guid => 'guid' },
        },
        
        CharacterInventory =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterInventory',
            column_map => { guid => 'guid' },
        },
        
        CharacterPet =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterPet',
            column_map => { guid => 'owner' },
        },

        CharacterQueststatus =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterQueststatus',
            column_map => { guid => 'guid' },
        },

        CharacterReputation =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterReputation',
            column_map => { guid => 'guid' },
        },

        CharacterSkills =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterSkills',
            column_map => { guid => 'guid' },
        },

        CharacterTicket =>
        {
            type => 'one to many',
            class => 'Mangos::DB::Characters::CharacterTicket',
            column_map => { guid => 'guid' },
        }
    ],

    primary_key_columns => [ 'guid' ],
);

1;

package Mangos::DB::Characters::Characters::Manager;

use strict;
use warnings;

use base 'Rose::DB::Object::Manager';

sub object_class { 'Mangos::DB::Characters::Characters' }

__PACKAGE__->make_manager_methods('characters');

1;
